//
//  ESTransmitAPI.h
//  ESTransmit
//
//  Created by zhiou on 2018/9/17.
//  Copyright © 2018年 excelsecu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ESTransmitterDefines.h"
@protocol ESTransmitterProtocol;
@class CBPeripheral;

extern NSString * const kESTransmitterStateNotification;

@protocol ESPairCodeDataSource<NSObject>
- (NSString *)pairCodeDidInput;
@end

@protocol ESTransmitDelegate <NSObject>
@end

@interface ESTransmitAPI : NSObject
@property (nonatomic, weak) id<ESPairCodeDataSource> delegate;
@property (nonatomic, assign) BOOL useForRPC;
@property (nonatomic, strong, readonly) id<ESTransmitterProtocol> transmitter;
+ (instancetype) sharedAPI;

/**
 异步接口，调用后尝试连接sn指定的key，如果sn与已连接的key不同，则先断开;
 界面请求由用户在ESTransmitDelegate中实现。
 @param sn 待连接的key的序列号，或扫描到的名称
 @keyType audio:1 ble:2
 @see   ESTransmitProtocol
 */
- (ESTransmitError)connect:(NSString *)sn withType:(int)keyType;


/**
 断开当前连接的key
 */
- (BOOL)disconnect;

- (NSData*)send:(NSData*)data;

- (NSInteger)lastError;

@end
